package com.hl.ui;

import java.util.ArrayList;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.hl.R;
import com.hl.adapter.OrderAllAdapter;
import com.hl.app.XiaoMiApplication;
import com.hl.bean.OrderBean;
import com.hl.util.LogUtils;
import com.hl.util.OrderUtils;

public class UserOrder{

	private MyOrderActivity activity;
	private View view;
	private OrderAllAdapter adapter;
	private ListView lv;
	private ArrayList<OrderBean> list;
		public UserOrder(final MyOrderActivity activity) { 
			super();
			this.activity=activity;
			
			view = activity.getLayoutInflater().inflate(R.layout.item_order_list, null);
			initView();
			lv.setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> arg0, View arg1,
						int position, long id) {
					// TODO Auto-generated method stub
					LogUtils.i("info", ""+position);
					OrderBean order = adapter.getItem(position);
					Intent intent =new Intent();
					intent.setClass(activity, DetailsActivity.class);
					intent.putExtra("order", order.getOrderNo()+"");
					intent.putExtra("state", order.getStatus());
					activity.startActivity(intent);
					activity.finish();
				}
			});
		}

		private void initView() {
			// TODO Auto-generated method stub
			lv = (ListView) view.findViewById(R.id.activity_center_myorder_listview_notuserorder);
			list=OrderUtils.checkOrderStatefinish(XiaoMiApplication.getInstance().alllist);
			adapter = new OrderAllAdapter(list, activity,"use");
			lv.setAdapter(adapter);
			
		}

	public View getView() {
		// TODO Auto-generated method stub
		return view;
	}

}
